home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr27 / p5bug10.zip / P5BUG.C < prev    next >
C/C++ Source or Header  |  1994-12-14  |  2KB  |  52 lines

  1. /*
  2.  
  3. Title:    P5BUG
  4. Date:    14 December 1994
  5. Author: William Luitje - luitje@m-net.arbornet.org
  6. Descr:    This program performs a simple test for the Pentium floating point
  7.     bug using the parameters found by Tim Coe.  If you modify this
  8.     program, don't forget to specify hardware floating point when you
  9.     re-compile it.    I compiled the code I released using Microsoft C
  10.     version 7.0 with the following switches:
  11.  
  12.     /Od /FPi87 /Gs
  13.  
  14. Rights: The author releases this program, both source and executable, into
  15.     the public domain.  You are responsible for your use of this program
  16.     and the decisions you make with the information it provides.
  17.  
  18. */
  19.  
  20. main()
  21. {
  22.     double test, error, x=4195835.0, y=3145727.0;
  23.     unsigned char far *EQUIPMENT = (unsigned char far *)0x00400010;
  24.  
  25.     printf("Pentium FPU bug checker, Version 1.0 by luitje@m-net.arbornet.org\n\n");
  26.  
  27.     if((*EQUIPMENT & 2) == 0) {
  28.     printf("No FPU detected.\n");
  29.     exit(1); }
  30.  
  31.     printf("This program will test the Floating Point Unit (FPU) of your Pentium\n");
  32.     printf("processor for an error which causes a loss of precision in some\n");
  33.     printf("particular floating point calculations.  The Pentium was produced\n");
  34.     printf("for almost two years before the problem was noticed so it's not a\n");
  35.     printf("common occurence but some calculations can be off by quite a bit.\n");
  36.     printf("According to Intel, the bug is present for all Pentiums built before\n");
  37.     printf("about October 1994 but is not known to occur in any other Intel FPU.\n\n");
  38.     printf("This program computes the following function:\n\n");
  39.     printf("error = 1.0 - (%.1f/%.1f)*%.1f\n\n",x,y,y);
  40.     printf("Mathematically, error is 0 but the Pentium computes 256!\n\n");
  41.  
  42.     test = x/y;
  43.     test = test * y;
  44.     error = x - test;
  45.     printf("Error is %1.20le\n\n",error);
  46.  
  47.     if(error > (double) 0.00000000001 || error < (double) -0.00000000001)
  48.     printf("Your Pentium is \"flawed\".\n");
  49.     else
  50.     printf("Your FPU passes this test.\n");
  51. }
  52.